GetLeavesByMonthQueryHandler.execute   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 7
c 0
b 0
f 0
rs 10
cc 1
1
import { Inject } from '@nestjs/common';
2
import { LeavesCollection } from 'src/Domain/HumanResource/Leave/LeavesCollection';
3
import { ILeaveRequestRepository } from 'src/Domain/HumanResource/Leave/Repository/ILeaveRequestRepository';
4
5
import { GetLeavesByMonthQuery } from './GetLeavesByMonthQuery';
6
7
export class GetLeavesByMonthQueryHandler {
8
  constructor(
9
    @Inject('ILeaveRequestRepository')
10
    private readonly leaveRequestRepository: ILeaveRequestRepository
11
  ) {}
12
13
  async execute(query: GetLeavesByMonthQuery): Promise<LeavesCollection> {
14
    const leaves = await this.leaveRequestRepository.findAcceptedLeaveRequestsByMonth(
15
      query.date
16
    );
17
18
    return new LeavesCollection(leaves);
19
  }
20
}
21